Skip to content

Rewrite sliding window bounds let at the correct loop level#9150

Merged
alexreinking merged 3 commits into
mainfrom
abadams/sliding_window_bounds_rewrite_level
May 27, 2026
Merged

Rewrite sliding window bounds let at the correct loop level#9150
alexreinking merged 3 commits into
mainfrom
abadams/sliding_window_bounds_rewrite_level

Conversation

@abadams
Copy link
Copy Markdown
Member

@abadams abadams commented May 22, 2026

Sliding window populates a replacements map keyed by .min/.max let names and rewrites the first matching LetStmt encountered on the way out from the producer. That happens to hit the right let today because we don't inject bounds for that Func anywhere else that we might hit first (e.g. inside a loop on the consumer side, which is visited after the producer). That's a shaky assumption though. It caused a bug in another branch where I added more .min/.max declaration sites for other purposes. This PR explicitly only rewrites the ones immediately inside the Produce node's loop. No test changes because there's no bug to trigger on main. This just makes the code more robust to future changes.

Sliding window populates a replacements map keyed by .min/.max let names
and rewrites the first matching LetStmt encountered on the way out from
the producer. That happens to hit the right let today because bounds
inference places the lets driving production at the producer's loop
nest level, but other lets with the same names can appear at deeper
loop nest levels on the consume side. Gate replacement on
enclosing_loops.size() matching the depth recorded when the producer
was visited, so only lets at the producer's loop level are rewritten.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@alexreinking
Copy link
Copy Markdown
Member

I'm not sure how the depth eliminates ambiguity. Does it merely make it less likely?

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@cb661ed). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/SlidingWindow.cpp 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9150   +/-   ##
=======================================
  Coverage        ?   69.41%           
=======================================
  Files           ?      254           
  Lines           ?    78221           
  Branches        ?    18714           
=======================================
  Hits            ?    54301           
  Misses          ?    18470           
  Partials        ?     5450           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@abadams
Copy link
Copy Markdown
Member Author

abadams commented May 22, 2026

There should be a single set of .min/.max lets per loop. But I guess you're saying there could be sibling loops at the depth of the produce node, multiple of which contain .min/.max lets, but only one of which actually contains the produce node? Perhaps I should change it to check the loop name instead of the depth.

@alexreinking
Copy link
Copy Markdown
Member

alexreinking commented May 23, 2026

correctness_truncated_pyramid is a new failure. Not the CI changes from #9077

@alexreinking alexreinking mentioned this pull request May 23, 2026
@abadams abadams force-pushed the abadams/sliding_window_bounds_rewrite_level branch from fe571ed to 9c2fe4a Compare May 25, 2026 20:38
Copy link
Copy Markdown
Member

@alexreinking alexreinking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like the correct fix now. Please update the PR / commit description.

@alexreinking alexreinking merged commit c65b8d1 into main May 27, 2026
32 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants